package com.hongyun.tms.common.enums;

import lombok.Getter;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 文件上传业务类型枚举
 *
 * @author ChenLP
 **/
@Getter
public enum FileUploadBusinessTypeEnum {

    BUSINESS_0001("0001", "", ""),
    BUSINESS_CONTRACT_01("BUSINESS_CONTRACT_01", "", "合同资料"),
    BUSINESS_CUSTOMER_AUTHORIZATION("BUSINESS_CUSTOMER_AUTHORIZATION", "", "授权书"),
    BUSINESS_CUSTOMER_BILLING("BUSINESS_CUSTOMER_BILLING", "", "企业开票"),
    BUSINESS_CUSTOMER_LICENSE("BUSINESS_CUSTOMER_LICENSE", "", "营业执照"),
    PAYMENT_PROOF("PAYMENT_PROOF", "", "付款凭证"),
    INVOICE_PROOF("INVOICE_PROOF", "", "发票证明"),
    BUSINESS_WATER("BUSINESS_WATER", "", "加水接电"),
    BUSINESS_TALLY("BUSINESS_TALLY", "", "理货"),
    MASTER_SHIP_01("MASTER_SHIP_01", "", "船舶资料"),
    REPORT_TEMPLATES("REPORT_TEMPLATES", "", "报表模板"),
    DISPATCH_TDISLOG("DISPATCH_TDISLOG", "", "调度日志"),
    HANDOVERLIST("HANDOVERLIST", "", "交接清单"),
    HANDOVERLIST_HG("HANDOVERLIST_HG", "", "交接清单-海关报关单"),
    HANDOVERLIST_JC("HANDOVERLIST_JC", "", "交接清单-第三方检测报告"),
    INVENTORY("INVENTORY", "", "作业通知单清单"),
    VERSION_CONTROL("VERSION_CONTROL", "", "版本控制"),
    BUSINESS_RECEIPT("BUSINESS_RECEIPT", "", "商务回执单"),
    SUNDRY_ACCESSORY("SUNDRY_ACCESSORY", "", "杂货计划附件"),
    CARGO_REDUCE_PROOF("CARGO_REDUCE_PROOF", "", "票货减免凭证"),
    ORDER_DELIVERY("ORDER_DELIVERY", "", "提货委托单"),
    BASE_VEHICLE_INFO("BASE_VEHICLE_INFO", "", "车辆资料"),
    SEMAN_CERT("SEMAN_CERT", "", "船员证件"),

    SAFETY_FILE("SAFETY_FILE", "", "安全管理文件"),

    //维修单---start
    REPAIR_BILL_QUALIFICATION("REPAIR_BILL_QUALIFICATION", "", "维修资质文件"),
    REPAIR_BILL_PHOTO("REPAIR_BILL_PHOTO", "", "维修照片"),
    //维修单---end

    //作业记录---start
    PORD_WORK_FINISH_WORK("PORD_WORK_FINISH_WORK", "", "作业记录完工照片"),
    //作业记录---end

    //培训计划---start
    TRAIN_PLAN_ATTACH("TRAIN_PLAN_ATTACH", "", "培训计划附件"),
    //培训计划---end

    //检查项目---start
    CHECK_ITEM("CHECK_ITEM", "", "检查项目附件"),
    //检查项目---end
    ;

    FileUploadBusinessTypeEnum(String code, String route, String comment) {
        this.code = code;
        this.route = route;
        this.comment = comment;
    }

    /**
     * 编码
     **/
    private final String code;

    /**
     * 路由
     **/
    private final String route;

    /**
     * 注释
     **/
    private final String comment;

    /**
     * 验证枚举
     *
     * @param code 编码
     * @return true|存在, false|不存在
     **/
    public static boolean valid(String code) {
        return Stream.of(FileUploadBusinessTypeEnum.values()).anyMatch(val -> val.getCode().equals(code));
    }
    /**
     * 获取业务类型
     *
     * @param code 编码
     * @return 业务类型
     **/
    public static String getRoute(String code) {
        Optional<FileUploadBusinessTypeEnum> opt = Stream.of(FileUploadBusinessTypeEnum.values())
                .filter(val -> val.getCode().equals(code)).findFirst();
        return opt.get().getRoute();
    }
}
